<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/static/zTree/css/metroStyle/metroStyle.css" />
		<style type="text/css">
			.form-group {
				margin-bottom: 10px
			}
			
			.checkForm label {
				width: 110px;
				display: block;
				float: left;
				margin-top: 7px;
				clear: both;
			}
			
			.checkForm {
				margin-bottom: 12px;
			}
			
			#contentWell {
				overflow-y: scroll;
				height: 240px;
				background: #fff;
			}
			
			#contentWell table {
				background-color: transparent;
				width: 100%;
				max-width: 100%;
				margin-bottom: 20px;
			}
			
			#contentWell table>tbody>tr>td,
			#contentWell table>tbody>tr>th,
			#contentWell table>tfoot>tr>td,
			#contentWell table>tfoot>tr>th,
			#contentWell table>thead>tr>td,
			#contentWell table>thead>tr>th {
				padding: 8px;
				line-height: 1.42857143;
				vertical-align: top;
				border-top: 1px solid #ddd;
			}
			
			#contentWell table>thead>tr>th {
				vertical-align: bottom;
				;
				border-bottom: 2px solid #ddd;
			}
			
			#contentWell table>caption+thead>tr:first-child>td,
			#contentWell table>caption+thead>tr:first-child>th,
			#contentWell table>colgroup+thead>tr:first-child>td,
			#contentWell table>colgroup+thead>tr:first-child>th,
			#contentWell table>thead:first-child>tr:first-child>td,
			#contentWell table>thead:first-child>tr:first-child>th {
				border-top: 0;
			}
			
			#contentWell table>tbody+tbody {
				border-top: 2px solid #ddd;
			}
			
			#contentWell table {
				border: 1px solid #ddd;
			}
			
			#contentWell table>tbody>tr>td,
			#contentWell table>tbody>tr>th,
			#contentWell table>tfoot>tr>td,
			#contentWell table>tfoot>tr>th,
			#contentWell table>thead>tr>td,
			#contentWell table>thead>tr>th {
				border: 1px solid #ddd;
			}
			
			#contentWell table>thead>tr>td,
			#contentWell table>thead>tr>th {
				border-bottom-width: 2px;
			}
			
			#contentWell img {
				display: inline-block;
				max-width: 100%;
				height: auto;
				padding: 4px;
				line-height: 1.42857143;
				background-color: #fff;
			}
			
			.ztree li span.button.icon03 {
				margin-top: 1px;
				background: url(static/common/frame/ztree/css/zTreeStyle/img/diy/001.png) no-repeat scroll 0 0 transparent;
				vertical-align: top;
				*vertical-align: middle
			}
			
			.ztree li span.button.icon03:hover {
				margin-top: 1px;
				background: url(static/common/frame/ztree/css/zTreeStyle/img/diy/002.png) no-repeat scroll 0 0 transparent;
				vertical-align: top;
				*vertical-align: middle
			}
			
			.ztree {
				overflow: auto
			}
		</style>
	</head>

	<body class="sticky-header">
		<div class="wrapper container-fluid">
			<div class="row">
				<ol class="breadcrumb col-xs-8">
					<li>
						<a href="javascript:;">积分管理</a>
					</li>
					<li>
						<a href="sell/goodsmaintenance">添加蛋糕</a>
					</li>
				</ol>
			</div>
		</div>

		<div class="workframe" id="formContent">
			<div class="container-fluid">
				<div class="row">
					<form id="cakesForm" action="" method="post">
						<input type="hidden" id="type" name="type" value="${type}" />
						<input type="hidden" id="sl" name="goods.sl" value="${goods.sl }" />
						<!-- 二期迭代修改部分：double类型税率 -->
						<input type="hidden" id="getSpbm" value="${goods.spbm }" />
						<!-- 二期迭代修改部分：spbm商品编码， -->
						<input type="hidden" id="getbm" name="goods.pjUserSpbmId" value="${goods.pjUserSpbmId }" />
						<!-- 二期迭代修改部分：pj_user的id， -->
						<input type="hidden" id="describeInfo" name="goods.describeInfo" value="${goodsVo.goods.describeInfo }" />
						<!-- wangyu修改部分：商品详情信息， -->
						<input type="hidden" id="hidden-bgfo" value="">
						<div class="col-xs-5">
							<div class="panel panel-default" style="min-height: 420px;">
								<div class="panel-heading">蛋糕信息</div>
								<div class="panel-body">
									<div class="form-group">
										<label>蛋糕编号</label>
										<input class="form-control" type="text" name="cakes.id" id="cakesId" value="" placeholder="蛋糕的编号" readonly="readonly" />
										<input type="hidden" id="state" name="cakes.state" value="" />
									</div>
									<div class="form-group">
										<label>蛋糕名称</label>
										<input class="form-control" type="text" name="cakes.name" value="" id="cakeName" placeholder="蛋糕的名称" readonly="readonly" />
									</div>
									<div class="form-group">
										<label>兑换积分</label>
										<input class="form-control" type="text" name="cakes.score" id="changeScore" value="" placeholder="用户兑换所需的积分" readonly="readonly">
									</div>
									<div class="form-group">
										<label for="name">对外价格</label>
										<input class="form-control" type="text" value="" id="outPrice" placeholder="展示给用户的价格" readonly="readonly" />
									</div>

									<div class="form-group">
										<label for="name">对账价格</label>
										<input class="form-control" type="text" value="" id="accountPrice" placeholder="公司实际支出的价格" readonly="readonly" />
									</div>
								</div>
							</div>
						</div>
						<div class="col-xs-7">
							<div class="panel panel-default" style="min-height: 420px;">
								<div class="panel-heading">预约信息</div>
								<div class="panel-body">
									<div class="form-group">
										<label>提前预约天数</label>
										<input class="form-control" type="text" name="advance" id="advance" value="" placeholder="提前预约天数" readonly="readonly" />
									</div>
									<div class="form-group">
										<label>可选门店</label>
										<ul id="ztree" class="ztree">
									</div>

								</div>
							</div>
						</div>
						<div class="col-xs-12">
							<div class="panel panel-default">
								<div class="panel-heading">蛋糕宣传信息</div>
								<div class="panel-body">
									<div class="form-group row">
										<div class="form-group  " id="imgCoverDiv">
											<label class="col-sm-2 control-label">宣传图片：</label>
											<div class="col-sm-8 text-center">
												<div class="well text-center" id="coverDiv" @click="uploadImg">
													<img src="http://iph.href.lu/200x150?text=宣传图片" id="coverImg" class="img-responsive img-thumbnail" alt="自定义">
												</div>
												<input type="hidden" name="cakes.coverImage" id="coverImage" value="" />
											</div>
										</div>
									</div>
									<br /> <br />
									<div class="form-group row" id="cakesDetail">
										<div class="form-horizontal text-left" style="height: 300px;overflow:auto; ">
											<div class="row" style="margin:0">

												<div class="col-md-6">
													<label>宣传文案<a class="btn btn-link" target="_blank" href="page/help/learnmarkdown.html" style="padding-right:0;">(点此查看markdown语法)</a>：</label>
													<button type="button" class="btn btn-primary btn-sm pull-right" style="margin-bottom: 5px;" @click="addImg">
                   							        <span class="glyphicon glyphicon-picture" ></span>&nbsp;上传图片</button>
													<textarea name="text-content" class="form-control" id="text-content" @keyup="tohtml" cols="30" rows="10" placeholder="请使用markdown语言编辑蛋糕介绍信息"></textarea></div>

												<div class="col-md-6">
													<label>预览：</label>
													<div class="well" id="contentWell"></div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="text-right col-xs-12">
							<a class="btn btn-primary" onclick="saveGoods(2);">保存</a>
							<a class="btn btn-primary" onclick="javascript:history.back(-1)">取消</a>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script src="/static/js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/bootstrap/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/zTree/js/jquery.ztree.all.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/js/component.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/js/csfwpt.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/markdown/showdown.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var urlObj = new UrlSearch();
			var vueBlock = new Vue({
				el: "#formContent",
				//数据部分 
				data: {
					ajaxurl: "integralGoods/goodList",
					searchData: {
						currentPage: 1
					},
					bean: {

					},
					setting: {
						view: {
							showLine: true,
							showTitle: true,
							selectedMulti: false
						},
						check: {
							enable: true,
							chkboxType: {
								"Y": "s",
								"N": "ps"
							}
						},
						edit: {
							enable: true
						},
						data: {
							simpleData: {
								enable: true
							}
						},
						callback: {

						}

					}
				},
				//方法
				methods: {
					tohtml: function() {
						var converter = new showdown.Converter();
						var val = $("#text-content").val();
						$("#contentWell").html(converter.makeHtml(val));
					},
					uploadImg: function() {
						$("#hidden-bgfo").val("cover");
						tool.openModal(null, null, "", 0, "showImage");
					},
					addImg: function() {
						$("#hidden-bgfo").val("addImg");
						tool.openModal(null, null, "", 0, "showImage");
					},
					showImage: function() {
						if(uploadResult.success) {
							var info = $("#hidden-bgfo").val();
							if(info == "cover") {
								$("#coverImage").val(uploadResult.files[0].url);
								$("#coverImg").attr("src", uploadResult.files[0].url);
								$("#coverImg").css("height", "120px");
							} else if(info == "detail") {
								$("#detailImage").val(uploadResult.files[0].url);
								$("#detailImg").attr("src", uploadResult.files[0].url);
								$("#detailImg").css("height", "120px");
							} else if(info == "addImg") {
								//插入到textarea中
								insertContent("![图片详情](" + uploadResult.files[0].url + ")\r\n", $("#text-content"));
								//更新MODEL,页面重新渲染
								tohtml();
							}
						}
					},
					reloadztree: function() {
						var zNodes = [{
							"id": 1,
							"pId": 0,
							"ordernum": "0",
							"name": "全部",
							"ctype": "root",
							"open": true
						}, {
							"id": 11,
							"pId": 1,
							"name": "通用平台",
							"ordernum": "0",
							"phone": "13821900283",
							"ctype": "单位",
							"open": true
						}, {
							"id": 111,
							"pId": 11,
							"name": "研发中心",
							"ordernum": "0",
							"phone": "13821900283",
							"ctype": "部门",
							"open": true
						}, {
							"id": 1111,
							"pId": 111,
							"name": "技术管理与知识产权",
							"ordernum": "0",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1112,
							"pId": 111,
							"name": "软件研发部",
							"ordernum": "1",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1113,
							"pId": 111,
							"name": "硬件研发部",
							"ordernum": "2",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1114,
							"pId": 111,
							"name": "天津研发部",
							"ordernum": "3",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1115,
							"pId": 111,
							"name": "测试部",
							"ordernum": "4",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 112,
							"pId": 11,
							"name": "支撑中心",
							"ordernum": "1",
							"phone": "13821900283",
							"ctype": "部门",
							"open": true
						}, {
							"id": 1121,
							"pId": 112,
							"name": "财务部",
							"ordernum": "0",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1122,
							"pId": 112,
							"name": "人事行政部",
							"ordernum": "1",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1123,
							"pId": 112,
							"name": "采购部",
							"ordernum": "2",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1124,
							"pId": 112,
							"name": "市场部",
							"ordernum": "3",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1125,
							"pId": 112,
							"name": "公关合作部",
							"ordernum": "4",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1126,
							"pId": 112,
							"name": "秘书组",
							"ordernum": "5",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1127,
							"pId": 112,
							"name": "IT部",
							"ordernum": "6",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 113,
							"pId": 11,
							"name": "3S事业部",
							"ordernum": "2",
							"phone": "13821900283",
							"ctype": "部门",
							"open": true
						}, {
							"id": 1132,
							"pId": 113,
							"name": "部委业务部",
							"ordernum": "1",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1133,
							"pId": 113,
							"name": "军工业务部",
							"ordernum": "2",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1134,
							"pId": 113,
							"name": "方案支持部",
							"ordernum": "3",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1135,
							"pId": 113,
							"name": "项目管理部",
							"ordernum": "4",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1136,
							"pId": 113,
							"name": "项目研发部",
							"ordernum": "5",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 12,
							"pId": 1,
							"name": "航天理想",
							"ordernum": "2",
							"phone": "13821900283",
							"ctype": "单位",
							"open": true
						}, {
							"id": 121,
							"pId": 12,
							"name": "北方区",
							"ordernum": "0",
							"phone": "13821900283",
							"ctype": "部门",
							"open": true
						}, {
							"id": 1211,
							"pId": 121,
							"name": "内蒙项目组",
							"ordernum": "0",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1212,
							"pId": 121,
							"name": "青海项目组",
							"ordernum": "1",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 1213,
							"pId": 121,
							"name": "公安部",
							"ordernum": "1",
							"phone": "13821900283",
							"ctype": "部门"
						}, {
							"id": 122,
							"pId": 12,
							"name": "河北区",
							"ordernum": "2",
							"phone": "13821900283",
							"ctype": "部门",
							"open": true
						}];
						//加载tree
						$.fn.zTree.init($("#ztree"), this.setting, zNodes);
						//根节点被选中
						var treeObj = $.fn.zTree.getZTreeObj("ztree");
						var node = treeObj.getNodeByParam("id", 1, null);
						treeObj.selectNode(node);
					}

				},
				//实时计算
				computed: {},
				//加载后立即执行的方法(created 这个钩子在实例被创建之后被调用)
				created: function() {
					this.reloadztree();
					if(urlObj.page) {
						this.searchData.currentPage = urlObj.page;
					}
				}
			});
		</script>
	</body>

</html>